#coding=utf-8

def getMapXY(i, w, h):
    #向0,0点平移
    x = i % w - int(w/2)
    y = int(h/2) - int(i/h) 
    return x, y

def getMapIndex(x, y , w, h):
    return x + int(w/2) + (int(h/2)-y) * h

""" test
print(0,1,2)
print(3,4,5)
print(6,7,8)

x,y = getMapXY(0, 3, 3)
print(x,y)
i = getMapIndex(1,-1,3,3)
print(i)
"""